<?php
/**
 * Created by PhpStorm.
 * User: boye009
 * Date: 2016/3/17
 * Time: 11:02
 */

namespace Test\Controller;

use Bbs\Api\ForumPostApi;
use Common\Api\BoyeServiceApi;

class TestForumPostController extends TestController{

    public function index(){
        $this->display();
    }

    public function query(){

        if(IS_POST){

            $data = array(
                'fid' => I('post.fid',''),
                'tid' => I('post.tid',''),
                'curpage' => I('post.curpage',''),
                'pagesize' => I('post.page',''),
                'maxcomment' => I('post.maxcomment'.''),
                'view_inc' => I('post.view_inc',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumPost_query',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }

    public function detail(){

        if(IS_POST){

            $data = array(
                'fid' => I('post.fid',''),
                'tid' => I('post.tid',''),
                'pid' => I('post.pid',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumPost_detail',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }

    public function commentQuery(){

        if(IS_POST){

            $data = array(
                'tid' => I('post.tid',''),
                'pid' => I('post.pid',''),
                'curpage' => I('post.curpage',''),
                'pagesize' => I('post.pagesize',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumPost_commentQuery',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }

    public function reply(){

        if(IS_POST){

            $data = array(
                'fid' => I('post.fid',''),
                'tid' => I('post.tid',''),
                'author' => I('post.author',''),
                'author_id' => I('post.author_id',''),
                'subject' => I('post.subject',''),
                'message' => I('post.message',''),
                'attachments' => I('post.attachments',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumPost_reply',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }

    public function Delete(){

        if(IS_POST){

            $data = array(
                'uid' => I('post.uid',''),
                'fid' => I('post.fid',''),
                'tid' => I('post.tid',''),
                'pid' => I('post.pid',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumPost_Delete',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }
        $this->display();
    }

    public function DeleteComment(){

        if(IS_POST){

            $data = array(
                'uid' => I('post.uid',''),
                'tid' => I('post.tid',''),
                'pid' => I('post.pid',''),
                'id' => I('post.id',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumPost_DeleteComment',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }
        $this->display();
    }

    public function replyPost(){

        if(IS_POST){

            $data = array(
                'pid' => I('post.pid',''),
                'tid' => I('post.tid',''),
                'author' => I('post.author',''),
                'author_id' => I('post.author_id',''),
                'comment' => I('post.comment',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ForumPost_replyPost',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }


    private function parseResult($result){
        echo "解密后数据：";
        dump($result);
    }

}